import type { Meta, StoryObj } from "@storybook/react";
import { fn } from "@storybook/test";
import "../../styles/index.scss";
import Tabs, { TabsMode, TabsSize } from "./tabs";
import TabItem from "./TabItem";
import Menu, { MenuMode } from "../Menu/menu";
import MenuItem from "../Menu/menuItem";
import SubMenu from "../Menu/subMenu";
// More on how to set up stories at: https://storybook.js.org/docs/writing-stories#default-export
const meta = {
  title: "components/Subs",
  component: Tabs,
  parameters: {
    // Optional parameter to center the component in the Canvas. More info: https://storybook.js.org/docs/configure/story-layout
    layout: "centered",
  },
  // This component will have an automatically generated Autodocs entry: https://storybook.js.org/docs/writing-docs/autodocs
  tags: ["autodocs"],
  // More on argTypes: https://storybook.js.org/docs/api/argtypes
  argTypes: {
    mode: {
      control: "radio",
      options: Object.values(TabsMode),
      description: "类型",
    },
    size: {
      control: "radio",
      options: Object.values(TabsSize),
      description: "类型",
    },
    defaultActiveKey: { control: "number", description: "默认选中" },
  },
  // Use `fn` to spy on the onClick arg, which will appear in the actions panel once invoked: https://storybook.js.org/docs/essentials/actions#action-args
  args: { onSelect: fn() },
} satisfies Meta<typeof Tabs>;

export default meta;
type Story = StoryObj<typeof meta>;

export const ComprehensiveCases: Story = {
  render: () => (
    <>
      <Tabs defaultActiveKey="0">
        <TabItem label="label1">label1</TabItem>
        <TabItem label="label2">label2</TabItem>
        <TabItem label="label3">label3</TabItem>
      </Tabs>
      <div style={{ height: "30px" }}></div>
      <Tabs defaultActiveKey="0" mode={TabsMode.Horizontal}>
        <TabItem label={<a href="#">assad</a>}></TabItem>
        <TabItem label="label1">
          <a href="#">assad</a>
        </TabItem>
        <TabItem label="label2">
          <Menu mode={MenuMode.Horizontal} defaultOpenSubMenus={["2-0"]}>
            <MenuItem>111</MenuItem>
            <MenuItem>222</MenuItem>
            <MenuItem disabled>222</MenuItem>
            <SubMenu title="dropdown">
              <MenuItem disabled>222</MenuItem>
              <MenuItem disabled>222</MenuItem>
              <MenuItem>111</MenuItem>
            </SubMenu>
          </Menu>
        </TabItem>
        <TabItem label="label4">label4</TabItem>
      </Tabs>
    </>
  ),
};
